package heliotrope.res
{
	import heliotrope.res.manager.GraphicLoadManager;
	
	import mx.resources.ResourceBundle;

	public class GraphicsPool
	{
		private var _characters:GraphicResource;
		private var _tilesets:TileSets;
		public function GraphicsPool(setting_:XML)
		{
			GraphicLoadManager.init();
			var tileSetting:XML = 
				<tileSetting>
					<tile id="9" numX="1" numY="1"/>
					<tile id="11" numX="50" numY="27"/>
				</tileSetting>;
			initTileSets(tileSetting);
			
			var characterSetting:XML =
				<characterSetting num="1">
					<cha id="0" name="CH20205.png" type="walk"/>
				</characterSetting>;
			initCharacters(characterSetting);
		}
		
		public function get characters():GraphicResource
		{
			return _characters;
		}

		public function get tilesets():TileSets
		{
			return _tilesets;
		}

		private function initTileSets(setting_:XML):void
		{
			var setVector:Vector.<TileSetting> = new Vector.<TileSetting>();
			for each(var tile:XML in setting_.tile)
			{
				setVector.push(new TileSetting(tile.@id, tile.@numX, tile.@numY));
			}
			_tilesets = new TileSets(setVector);
		}
		
		private function initCharacters(characterSetting:XML):void
		{
			var setVector:Vector.<String> = new Vector.<String>();
			_characters = new GraphicResource("Characters", setVector);
		}
	}
}